home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pp / pp-6.0 / Lib / qmgr / chan_debug.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-18  |  3.6 KB  |  154 lines

  1. /* chan_debug.c: stub version of chan_control for debugging channel */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Lib/qmgr/RCS/chan_debug.c,v 6.0 1991/12/18 20:23:58 jpo Rel $";
  5. # endif
  6.  
  7. /*
  8.  * $Header: /xtel/pp/pp-beta/Lib/qmgr/RCS/chan_debug.c,v 6.0 1991/12/18 20:23:58 jpo Rel $
  9.  *
  10.  * $Log: chan_debug.c,v $
  11.  * Revision 6.0  1991/12/18  20:23:58  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16.  
  17.  
  18. #include        "util.h"
  19. #include        "qmgr.h"
  20. static void pdeliverystatus (), pindividualdeliverystatus ();
  21.  
  22.  
  23. /* ARGSUSED */
  24. int debug_channel_control (argc, argv, init, work, finish)
  25. int     argc;
  26. char    **argv;
  27. IFP     init;
  28. struct type_Qmgr_DeliveryStatus *(*work)();
  29. IFP    finish;
  30. {
  31.     char    channel[BUFSIZ],
  32.         buf[BUFSIZ];
  33.     int     cont = TRUE,
  34.         num;
  35.     struct type_Qmgr_ProcMsg arg;
  36.     struct type_Qmgr_UserList *temp = NULL,
  37.                   *tail = NULL;
  38.     struct type_Qmgr_DeliveryStatus *result;
  39.  
  40.     if (isatty (2))
  41.         pp_log_norm -> ll_stat |= LLOGTTY;
  42.     /* input channel structure */
  43.     printf("Input channel name : ");
  44.     if (scanf(" %s",channel) != 1)
  45.         return NOTOK;
  46.     arg.channel = str2qb(channel,strlen(channel),1);
  47.     arg.qid = NULL;
  48.     arg.users = NULL;
  49.  
  50.     if ((*init)(arg.channel) == OK) {
  51.         printf("Channel initialised\n");
  52.         while(cont == TRUE) {
  53.             if (arg.users != NULL) free_Qmgr_UserList(arg.users);
  54.             arg.users = NULL;
  55.             if (arg.qid != NULL) qb_free(arg.qid);
  56.             arg.qid = NULL;
  57.  
  58.             temp = tail = NULL;
  59.  
  60.             printf("Input message id : ");
  61.             if (scanf(" %s",buf) != 1)
  62.                 return NOTOK;
  63.  
  64.             arg.qid = str2qb(buf,strlen(buf),1);
  65.  
  66.             printf("Input recipient numbers to pass to channel terminated by -1\n\t : ");
  67.             if (scanf(" %d",&num) != 1)
  68.                 return NOTOK;
  69.  
  70.             while (num != -1) {
  71.                 temp = (struct type_Qmgr_UserList *) calloc(1, sizeof(*temp));
  72.                 temp->RecipientId = (struct type_Qmgr_RecipientId *) calloc(1,sizeof(*(temp->RecipientId)));
  73.                 temp->RecipientId->parm = num;
  74.                 if (arg.users == NULL) 
  75.                     arg.users = tail = temp;
  76.                 else {
  77.                     tail->next = temp;
  78.                     temp = temp;
  79.                 }
  80.                 if (scanf("%d",&num) != 1)
  81.                     return NOTOK;
  82.             }
  83.  
  84.             result = (*work) (&arg);
  85.             pdeliverystatus(result);
  86.  
  87.             printf("Do you want to continue ");
  88.             do {
  89.                 printf("(y/n) ? ");
  90.                 if (scanf("%s", buf) != 1)
  91.                     return NOTOK;
  92.             } while (index("yn",*buf) == NULL);
  93.             cont = (*buf == 'y') ? TRUE : FALSE;
  94.         }
  95.         if (finish != NULLIFP)
  96.             (*finish) ();
  97.     } else 
  98.         printf("Channel initialisation failed\n");
  99.     return OK;
  100. }
  101.  
  102. static void pdeliverystatus (status)
  103. struct type_Qmgr_DeliveryStatus *status;
  104. {
  105.     printf ("Delivery status\n");
  106.     if (status == NULL)
  107.         printf ("Complete failure\n");
  108.     else {
  109.         struct type_Qmgr_DeliveryStatus *ix = status;
  110.         while (ix != NULL)
  111.         {
  112.             pindividualdeliverystatus(ix->IndividualDeliveryStatus);
  113.             ix = ix->next;
  114.         }
  115.     }
  116. }
  117.  
  118. static void pindividualdeliverystatus(status)
  119. struct type_Qmgr_IndividualDeliveryStatus *status;
  120. {
  121.     printf ("Recipient %d: ", status->recipient->parm);
  122.  
  123.     switch (status->status) {
  124.         case int_Qmgr_status_success:
  125.         printf ("success");
  126.         break;
  127.         case int_Qmgr_status_successSharedDR:
  128.         printf ("successSharedDR");
  129.         break;
  130.         case int_Qmgr_status_failureSharedDR:
  131.         printf ("failureSharedDR");
  132.         break;
  133.         case int_Qmgr_status_negativeDR:
  134.         printf ("negativeDR");
  135.         break;
  136.         case int_Qmgr_status_positiveDR:
  137.         printf ("positiveDR");
  138.         break;
  139.         case int_Qmgr_status_messageFailure:
  140.         printf ("message failure");
  141.         break;
  142.         case int_Qmgr_status_mtaFailure:
  143.         printf ("mta failure");
  144.         break;
  145.         case int_Qmgr_status_mtaAndMessageFailure:
  146.         printf ("mta and message failure");
  147.         break;
  148.         default:
  149.         printf ("unknown");
  150.         break;
  151.     }
  152.     (void) putchar ('\n');
  153. }
  154.